<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="transactionId">
              <a-input placeholder="请输入transactionId" v-model="queryParam.transactionId"></a-input>
            </a-form-item>
          </a-col> -->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="支付金额">
              <a-input placeholder="请输入支付金额" v-model="queryParam.amount"></a-input>
            </a-form-item>
          </a-col>
        <template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单类型">
				<a-select v-model="queryParam.type" placeholder="请选择订单类型">
				  <a-select-option :value="item.id" v-for="(item,index) in typeList" :key="index">{{item.name}}</a-select-option>
				</a-select>
<!--              <a-input placeholder="请输入1押金 2定金 3尾款  4工资" v-model="queryParam.type"></a-input> -->
            </a-form-item>
          </a-col>
          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="remarks">
              <a-input placeholder="请输入remarks" v-model="queryParam.remarks"></a-input>
            </a-form-item>
          </a-col> -->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.orderId"></a-input>
            </a-form-item>
          </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
     <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
    <!--  <a-button type="primary" icon="download" @click="handleExportXls('交易流水')">导出</a-button> -->
      <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
		 @change="handleTableChange">
         <span slot="type" slot-scope="text, record">
			 {{typeList[text].name}}
		</span>
        <span slot="action" slot-scope="text, record">
		  
		  <a v-if="record.tradeState == 'SUCCESS' && record.type < 4 && record.status == 0 && record.backStatus != 1" @click="handlebackMoney(record)">退款</a>
			
		  <a-divider v-if="record.tradeState == 'SUCCESS' && record.type < 4 && record.status == 0 && record.backStatus != 1"  type="vertical" />
          <!-- <a @click="handleEdit(record)">编辑</a> -->

          <!-- <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown> -->
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <wechatTransactionFlow-modal ref="modalForm" @ok="modalFormOk"></wechatTransactionFlow-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import WechatTransactionFlowModal from './modules/WechatTransactionFlowModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'
  export default {
    name: "WechatTransactionFlowList",
    mixins:[JeecgListMixin],
    components: {
      WechatTransactionFlowModal
    },
    data () {
      return {
        description: '交易流水管理页面',
		typeList:[{
			id:0,
			name:'全部'
		},{
			id:1,
			name:'押金'
		},{
			id:2,
			name:'定金'
		},{
			id:3,
			name:'尾款'
		},{
			id:4,
			name:'工资'
		},{
			id:5,
			name:'佣金'
		}],
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          //  },
		   {
            title: '支付金额(元)',
            align:"center",
            dataIndex: 'amount'
           },
		   {
            title: '订单类型', // 1押金 2定金 3尾款  4工资 5佣金
            align:"center",
            dataIndex: 'type',
			scopedSlots: { customRender: 'type' },
           },
		   {
		    title: '订单号',
		    align:"center",
		    dataIndex: 'orderId'
		   },
		   {
		    title: '支付结果',
		    align:"center",
		    dataIndex: 'tradeState'
		   },
		   {
		    title: '支付类型',
		    align:"center",
		    dataIndex: 'tradeType'
		   },
		   {
		    title: '创建时间',
		    align:"center",
		    dataIndex: 'createTime'
		   },
		   {
		    title: '支付时间',
		    align:"center",
		    dataIndex: 'updateTime'
		   },
		   {
            title: '备注',
            align:"center",
            dataIndex: 'remarks'
           },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/wechat/transactionFlow/list",
          delete: "/wechat/wechatTransactionFlow/delete",
          deleteBatch: "/wechat/wechatTransactionFlow/deleteBatch",
          exportXlsUrl: "wechat/wechatTransactionFlow/exportXls",
          importExcelUrl: "wechat/wechatTransactionFlow/importExcel",
		  backMoneyUrl:'/wechat/transactionFlow/backMoney'
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
      handlebackMoney(item){
		  getAction(this.url.backMoneyUrl,{id:item.id}).then(res => {
			  if(res.code == 200){
				  this.loadData(1);
			  }
		  })
	  }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>